import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'

Vue.use(Vuex)
const __require__ = require.context('./modules', true, /\.js$/)
const modules = __require__.keys().reduce((modules, modulePath) => {
    const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
    const module = __require__(modulePath)
    modules[moduleName] = module.default
    return modules
}, {})
const store = new Vuex.Store({
    modules,
    getters
})

export default store
